package com.qiyu.tech.tcc.starter;

import com.baomidou.mybatisplus.plugins.PerformanceInterceptor;
import com.qiyu.datasource.annotation.AppDataSource;
import com.qiyu.datasource.enums.DatasourceConfigEnum;
import com.qiyu.datasource.enums.SupportDatasourceEnum;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;

import java.util.Properties;

/**
 * @author linhao
 * @date created in 7:02 下午 2020/11/3
 */
@SpringBootApplication(scanBasePackages = "com.qiyu.*")
@AppDataSource(datasourceType = {DatasourceConfigEnum.TEST_ORDER_DB,DatasourceConfigEnum.TEST_GOODS_DB,DatasourceConfigEnum.TEST_USER_DB},defaultType = DatasourceConfigEnum.TEST_ORDER_DB)
public class TccApplication {

    /**
     * 打印 sql
     */
    @Bean
    public PerformanceInterceptor performanceInterceptor() {
        PerformanceInterceptor performanceInterceptor = new PerformanceInterceptor();
        //格式化sql语句
        Properties properties = new Properties();
        properties.setProperty("format", "false");
        performanceInterceptor.setProperties(properties);
        return performanceInterceptor;
    }

    public static void main(String[] args) {
        SpringApplication.run(TccApplication.class);
    }
}
